<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./Vue.js"></script>
    <style>
        .color {
            background-color: pink;
        }
    </style>
</head>

<body>
    <ul class="ul">
        <li v-for="i,index in list" :class="con===index?'color':''" @click="tai(index)">
            {{i}}
        </li>
    </ul>
    <script>
        const obj = {
            data() {
                return {
                    list: ["胡歌","彭于晏","韩立","我"],
                    con: 0
                }
            },
            methods: {
                tai(index) {
                    console.log(index);
                    this.con = index
                }
            }
        }
        Vue.createApp(obj).mount('.ul')
    </script>
</body>

</html>